var t = getApp();

Page({
    data: {
        status: "",
        config_status: "",
        config2: {},
        config3: {},
        config4: {},
        config5: {},
        username: "",
        password: "",
        password_again: ""
    },
    onLoad: function(t) {
        this.setData({
            status: "",
            config_status: ""
        }), this.getData();
    },
    onChange: function(t) {
        var a = t.detail;
        this.setData({
            username: a
        });
    },
    onChange_p: function() {
        var t = e.detail;
        this.setData({
            password: t
        });
    },
    onChange_p2: function() {
        var t = e.detail;
        this.setData({
            password_again: t
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var a = this, n = t.getNetAddresss("plugin.merchant.frontend.get-center-condition");
        t._getNetWork({
            url: n,
            success: function(t) {
                var n = t.data;
                1 === n.result ? (a.setData({
                    status: n.data.status,
                    config_status: n.data.config_status,
                    config2: n.data.config2,
                    config3: n.data.config3,
                    config4: n.data.config4,
                    config5: n.data.config5,
                    independent_backend: n.data.independent_backend
                }), n.data.lang && (a.setData({
                    title: n.data.lang.title,
                    merchant_center: n.data.lang.merchant_center
                }), wx.setNavigationBarTitle({
                    title: "".concat(a.data.merchant_center, "申请")
                }))) : wx.showToast({
                    title: n.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    submit: function() {
        var a = this;
        if (3 != a.data.config_status && 1 == a.data.independent_backend && (t._isTextEmpty(username) || t._isTextEmpty(password) || t._isTextEmpty(password_again))) wx.showToast({
            title: "请填写账号信息",
            icon: "none",
            duration: 1e3
        }); else {
            var n = {
                config_status: this.data.config_status,
                user: {
                    username: a.data.username,
                    password: a.data.password,
                    password_again: a.data.password_again
                }
            }, e = t.getNetAddresss("plugin.merchant.frontend.merchant-apply.center");
            t._getNetWork({
                url: e,
                data: n,
                success: function(t) {
                    var n = t.data;
                    if (1 === n.result) a.setData({
                        status: n.data.status
                    }); else {
                        if (-4 == n.data.status) return void wx.showToast({
                            title: n.msg,
                            icon: "none",
                            success: function(t) {
                                wx.navigateTo({
                                    url: "packageB/member/enterprise/enterprise_apply/enterprise_apply"
                                });
                            }
                        });
                        wx.showToast({
                            title: n.msg,
                            icon: "none"
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    goHome: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    },
    goToGoods: function(t) {
        var a = t.currentTarget.dataset.id || t.target.dataset.id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    goEnterproseCentre: function() {
        wx.navigateTo({
            url: "/packageB/member/enterprise/enterprise_index/enterprise_index"
        });
    }
});